#include "main.h"

void clk_enbale(void)
{
    CCM_CCGR0 = 0xffffffff;
    CCM_CCGR1 = 0xffffffff;
    CCM_CCGR2 = 0xffffffff;
    CCM_CCGR3 = 0xffffffff;
    CCM_CCGR4 = 0xffffffff;
    CCM_CCGR5 = 0xffffffff;
    CCM_CCGR6 = 0xffffffff;
}

void led_init(void)
{
    SW_MUX_GPIO5_IO03 = 0x05;
    SW_PAD_GPIO5_IO03 = 0x10b0;

    GPIO5_GDIR = 0x8;
    // GPIO5_DR = 0;
}

void delay_short(volatile unsigned int n)
{
    while (n--)
    {
        /* code */
    }    
}

void delay_ms(volatile unsigned int ms)
{
    while (ms--)
    {
        delay_short(0x7ff);
    }    
}

void led_on(void)
{
    GPIO5_DR &= ~(1<<3);
}

void led_off(void)
{
    GPIO5_DR |= (1<<3);
}

int main(void)
{
    clk_enbale();
    led_init();
    led_on();
    
    while (1)
    {
        led_on();
        delay_ms(500);
        led_off();
        delay_ms(500);
    }
    return 0;    
}